//
//  MyDianPuViewController.m
//  EJLX
//
//  Created by xufei on 15/12/14.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "MyDianPuViewController.h"
#import "HuoQuDianPuSheZhi.h"
#import "GoodsAdress.h"
@interface MyDianPuViewController ()

@end

@implementation MyDianPuViewController
-(void)viewWillAppear:(BOOL)animated
{
    [HttpsManager requestGetDianPuSheZhi:^(NSMutableArray *xinXiAry)
     {
         if (xinXiAry!=nil)
         {
             _dataAry=xinXiAry;
             [self dianPuXinXi];
             [self dingDan];
             [self sheZhi];
         }
         else
         {
             LoginVC*vc=[[LoginVC alloc]init];
             [self.navigationController pushViewController:vc animated:YES];
         }
         
     }];

}
- (void)viewDidLoad {
    [super viewDidLoad];
   // _time1=@"0";
    //_time2=@"0";
    [self sheZhi];
    [self touXiang];
    // Do any additional setup after loading the view from its nib.
}

-(void)sheZhi
{
    HuoQuDianPuSheZhi*sheZhi=_dataAry[0];
    self.view.backgroundColor=RGB(240, 240, 240);
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 20,WIDE, 44)];
    view.backgroundColor=RGB_COLOR(0x00c49f);
    
    [self.view addSubview:view];
    UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/2-40, 10,80, 24)];
    label.text=@"店铺设置";
    label.textColor=[UIColor whiteColor];
    label.textAlignment=NSTextAlignmentCenter;
    [view addSubview:label];
    UIButton*backBut=[[UIButton alloc]initWithFrame:CGRectMake(10,7,30,30)];
    [backBut setImage:[UIImage imageNamed:@"返回箭头"] forState:UIControlStateNormal];
    [backBut addTarget:self action:@selector(backBut) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:backBut];
    UIButton*but=[[UIButton alloc]initWithFrame:CGRectMake(WIDE-60, 10,40, 15)];
    [but setTitle:@"保存" forState:UIControlStateNormal];
    but.font=[UIFont systemFontOfSize:12];
    [but addTarget:self action:@selector(gengXin) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:but];
    UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0,64,WIDE, 70)];
    view1.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view1];
    UIImageView*jianTou1=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,25,20,20)];
    jianTou1.image=[UIImage imageNamed:@"右箭头"];
    [view1 addSubview:jianTou1];
    headImage=[[UIImageView alloc]initWithFrame:CGRectMake(5,10,50,50)];
    [headImage sd_setImageWithURL:[NSURL URLWithString:sheZhi.avatar] placeholderImage:[UIImage imageNamed:@"头像"]];
    [view1 addSubview:headImage];
    UILabel*headLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,10,WIDE, 70)];
    headLabel.text=@"上传店铺图标";
    headLabel.font=[UIFont systemFontOfSize:12];
    headLabel.textAlignment=NSTextAlignmentCenter;
    headLabel.textColor=[UIColor blackColor];
    [view1 addSubview:headLabel];
    UIButton*but1=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE, 70)];
    [but1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but1.tag=1;
    [view1 addSubview:but1];
    UIView*view2=[[UIView alloc]initWithFrame:CGRectMake(0,64+71,WIDE,40)];
    view2.backgroundColor=[UIColor whiteColor];
    UIImageView*jianTou2=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,5,20,20)];
    jianTou2.image=[UIImage imageNamed:@"右箭头"];
    [view2 addSubview:jianTou2];
    [self.view addSubview:view2];
    
    UILabel*dianZhaoLabel=[[UILabel alloc]initWithFrame:CGRectMake(5,0,50,40)];
    dianZhaoLabel.textColor=[UIColor blackColor];
    dianZhaoLabel.text=@"店铺招牌";
    dianZhaoLabel.font=[UIFont systemFontOfSize:12];
    [view2 addSubview:dianZhaoLabel];
    dianZhao=[[UILabel alloc]initWithFrame:CGRectMake(50,0,WIDE-50,40)];
    dianZhao.text=@"未上传";
    dianZhao.font=[UIFont systemFontOfSize:12];
    dianZhao.textAlignment=NSTextAlignmentCenter;
    [view2 addSubview:dianZhao];
    UIButton*but2=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE,40)];
    [but2 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but2.tag=2;
    [view2 addSubview:but2];
    [self dianPuXinXi];
    UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(0, 10+64+71+10+40+40+1+1+40+30,WIDE,40)];
    label1.text=@"自营商品设置";
    label1.font=[UIFont systemFontOfSize:12];
    label1.textColor=[UIColor blackColor];
    
    [self.view addSubview:label1];
    [self ziYingShangPin];

}
-(void)touXiang
{
    UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0,64,WIDE, 70)];
    view1.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view1];
    UIImageView*jianTou1=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,25,20,20)];
    jianTou1.image=[UIImage imageNamed:@"右箭头"];
    [view1 addSubview:jianTou1];
    headImage=[[UIImageView alloc]initWithFrame:CGRectMake(5,10,50,50)];
    //[headImage sd_setImageWithURL:[NSURL URLWithString:sheZhi.avatar] placeholderImage:[UIImage imageNamed:@"头像"]];
    headImage.image=_image;
    [view1 addSubview:headImage];
    UILabel*headLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,10,WIDE, 70)];
    headLabel.text=@"上传店铺图标";
    headLabel.font=[UIFont systemFontOfSize:12];
    headLabel.textAlignment=NSTextAlignmentCenter;
    headLabel.textColor=[UIColor blackColor];
    [view1 addSubview:headLabel];
    UIButton*but1=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE, 70)];
    [but1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but1.tag=1;
    [view1 addSubview:but1];

}
-(void)ziYingShangPin
{
    HuoQuDianPuSheZhi*sheZhi=_dataAry[0];
    UIView*view6=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+1+1+40+30+40, WIDE,40)];
    view6.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view6];
    UILabel*addressLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50,40)];
    addressLabel.text=@"收货地址";
    addressLabel.font=[UIFont systemFontOfSize:12];
    addressLabel.textColor=[UIColor blackColor];
    [view6 addSubview:addressLabel];
    addressLabel1=[[UILabel alloc]initWithFrame:CGRectMake(50,0,WIDE-50,40)];
    if ([sheZhi.address length])
    {
        addressLabel1.text=@"未填写";
    }
    else
    {
        addressLabel1.text=@"已填写";
    }
    addressLabel1.font=[UIFont systemFontOfSize:12];
    addressLabel1.textAlignment=NSTextAlignmentCenter;
    [view6 addSubview:addressLabel1];
    UIButton*but6=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE,40)];
    [but6 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but6.tag=6;
    [view6 addSubview:but6];
        UIView*view7=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+1+1+40+30+40+45-4,WIDE,40)];
        view7.backgroundColor=[UIColor whiteColor];
        [self.view addSubview:view7];
        UILabel*dingDanLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,90,40)];
        dingDanLabel.text=@"订单自动关闭";
        dingDanLabel.font=[UIFont systemFontOfSize:12];
        dingDanLabel.textColor=[UIColor blackColor];
        [view7 addSubview:dingDanLabel];
       dingDanLabel1=[[UILabel alloc]initWithFrame:CGRectMake(50,0, WIDE-50,40)];
   // NSLog(@"zzzz%d",sheZhi.closeminute);
//    int za=sheZhi.closeminute/3600;
//    int zb=sheZhi.closeminute%3600/60;
    //_time1=[NSString stringWithFormat:@"%d",za];
    //_time2=[NSString stringWithFormat:@"%d",zb];
        dingDanLabel1.text=[NSString stringWithFormat:@"%@小时%@分钟",_time1,_time2];
        dingDanLabel1.font=[UIFont systemFontOfSize:12];
        dingDanLabel1.textAlignment=NSTextAlignmentCenter;
        [view7 addSubview:dingDanLabel1];
    //[self dingDan];
    UIImageView*jianTou6=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,4,20,20)];
    jianTou6.image=[UIImage imageNamed:@"右箭头"];
    [view6 addSubview:jianTou6];
        UIImageView*jianTou7=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,4,20,20)];
        jianTou7.image=[UIImage imageNamed:@"右箭头"];
        [view7 addSubview:jianTou7];
        UIButton*but7=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE,40)];
        [but7 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
        but7.tag=7;
        [view7 addSubview:but7];
    UIView*view8=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+1+1+40+30+40+45-4+40+1,WIDE,40)];
    view8.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view8];
    UILabel*jiaoYiLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,90,40)];
    jiaoYiLabel.text=@"七天担保交易";
    jiaoYiLabel.font=[UIFont systemFontOfSize:12];
    jiaoYiLabel.textColor=[UIColor blackColor];
    [view8 addSubview:jiaoYiLabel];
    jiaoYiLabel1=[[UILabel alloc]initWithFrame:CGRectMake(50,0,WIDE-50,40)];
    jiaoYiLabel1.text=@"未开通";
    jiaoYiLabel1.font=[UIFont systemFontOfSize:12];
    jiaoYiLabel1.textAlignment=NSTextAlignmentCenter;
    [view8 addSubview:jiaoYiLabel1];
    UIImageView*jianTou8=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,4,20,20)];
    jianTou8.image=[UIImage imageNamed:@"右箭头"];
    [view8 addSubview:jianTou8];
    UIButton*but8=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE,40)];
    [but8 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but8.tag=8;
    [view8 addSubview:but8];

}
-(void)dianPuXinXi
{
    HuoQuDianPuSheZhi*sheZhi=_dataAry[0];
    UIView*view3=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40, WIDE,40)];
    view3.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view3];
    UILabel*nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50,40)];
    nameLabel.text=@"店铺名称";
    nameLabel.font=[UIFont systemFontOfSize:12];
    nameLabel.textColor=[UIColor blackColor];
    [view3 addSubview:nameLabel];
    nameField=[[UITextField alloc]initWithFrame:CGRectMake(60, 0,WIDE-60,40)];
    nameField.placeholder=@"请输入店铺名称";
    nameField.text=sheZhi.name;
    nameField.font=[UIFont systemFontOfSize:12];
    [view3 addSubview:nameField];
    UIView*view4=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+1,WIDE,40)];
    view4.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view4];
    weatchLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50,40)];
    weatchLabel.text=@"微信号";
    weatchLabel.font=[UIFont systemFontOfSize:12];
    weatchLabel.textColor=[UIColor blackColor];
    [view4 addSubview:weatchLabel];
    weatchField=[[UITextField alloc]initWithFrame:CGRectMake(60, 0,WIDE-60,40)];
    weatchField.placeholder=@"请输入微信号";
    weatchField.text=sheZhi.wechat;
    weatchField.font=[UIFont systemFontOfSize:12];
    [view4 addSubview:weatchField];
    UIView*view5=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+40+1+1,WIDE,40)];
    view5.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view5];
    UILabel*phoneLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50,40)];
    phoneLabel.text=@"客服电话";
    phoneLabel.font=[UIFont systemFontOfSize:12];
    phoneLabel.textColor=[UIColor blackColor];
    [view5 addSubview:phoneLabel];
    phoneField=[[UITextField alloc]initWithFrame:CGRectMake(60, 0,WIDE-60, 40)];
    phoneField.placeholder=@"请输入客服电话";
    phoneField.text=sheZhi.phone;
    phoneField.font=[UIFont systemFontOfSize:12];
    [view5 addSubview:phoneField];

}
-(void)dingDan
{
    HuoQuDianPuSheZhi*sheZhi=_dataAry[0];
    UIView*view7=[[UIView alloc]initWithFrame:CGRectMake(0,64+71+10+40+40+1+1+40+30+40+45-4,WIDE,40)];
    view7.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view7];
    UILabel*dingDanLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,90,40)];
    dingDanLabel.text=@"订单自动关闭";
    dingDanLabel.font=[UIFont systemFontOfSize:12];
    dingDanLabel.textColor=[UIColor blackColor];
    [view7 addSubview:dingDanLabel];
    dingDanLabel1=[[UILabel alloc]initWithFrame:CGRectMake(50,0, WIDE-50,40)];
   // if ([sheZhi.closeminute isKindOfClass:[NSNull class]])
    //{
        
       // int za=0/3600;
       // int zb=0%3600/60;
        //_time1=[NSString stringWithFormat:@"%d",za];
        //_time2=[NSString stringWithFormat:@"%d",zb];
   // }
    //else
   // {
    //if ( !NULL== sheZhi.closeminute) {
    
        int za=sheZhi.closeminute/3600;
       int zb=sheZhi.closeminute%3600/60;
       _time1=[NSString stringWithFormat:@"%d",za];
       _time2=[NSString stringWithFormat:@"%d",zb];

    //}
    
          // }
    
    dingDanLabel1.text=[NSString stringWithFormat:@"%@小时%@分钟",_time1,_time2];
    dingDanLabel1.font=[UIFont systemFontOfSize:12];
    dingDanLabel1.textAlignment=NSTextAlignmentCenter;
    [view7 addSubview:dingDanLabel1];

    UIImageView*jianTou7=[[UIImageView alloc]initWithFrame:CGRectMake(WIDE-30,4,20,20)];
    jianTou7.image=[UIImage imageNamed:@"右箭头"];
    [view7 addSubview:jianTou7];
    UIButton*but7=[[UIButton alloc]initWithFrame:CGRectMake(0, 0,WIDE,40)];
    [but7 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    but7.tag=7;
    [view7 addSubview:but7];
}
-(void)butClick:(UIButton*)sender
{
    switch (sender.tag)
    {
        case 1:
        {
            NSLog(@"1");
            UIImagePickerController * vc = [[UIImagePickerController alloc]init];
            [self presentViewController:vc animated:YES completion:nil];
            
            vc.delegate  =self ;
            vc.allowsEditing = YES ;
            _c=1;
            
        }
            break;
        case 2:
        {
            UIImagePickerController * vc = [[UIImagePickerController alloc]init];
            [self presentViewController:vc animated:YES completion:nil];
            
            vc.delegate  =self ;
            vc.allowsEditing = YES ;
            _c=2;

            NSLog(@"2");
        }
            break;
        case 6:
        {
            GoodsAdress *adress = [[GoodsAdress alloc] init];
            
            [self.navigationController pushViewController:adress animated:YES];
        
        }
            break;
        case 7:
        {
            _a=0;
            _b=0;
            dingDanView=[[UIView alloc]initWithFrame:CGRectMake(20, 150, WIDE-40,300)];
            dingDanView.backgroundColor=[UIColor grayColor];
            [self.view addSubview:dingDanView];
            UILabel*zY=[[UILabel alloc]initWithFrame:CGRectMake(10, 10,70, 30)];
            zY.text=@"有效期";
            zY.font=[UIFont boldSystemFontOfSize:20];
            zY.textColor=[UIColor greenColor];
            [dingDanView addSubview:zY];
            UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(0,50, dingDanView.frame.size.width, 2)];
            label1.backgroundColor=[UIColor greenColor];
            [dingDanView addSubview:label1];
            for (int i=0; i<4; i++)
            {
                int a=i/2;   //0,0,1,1
                int b=i%2;     //0,1,0,1
                NSLog(@"a==%d",a);
                NSLog(@"b==%d",b);
                UIButton*but=[[UIButton alloc]initWithFrame:CGRectMake(dingDanView.frame.size.width/2-100+(100+30)*a, 80+90*b,100,40)];
                NSArray*ary=[NSArray arrayWithObjects:@"加号",@"减号",@"加号",@"减号", nil];
                [but setImage:[UIImage imageNamed:ary[i]] forState:UIControlStateNormal];
                
                //[but setTitle:ary[i] forState:UIControlStateNormal];
                but.tag=i;
                //but.backgroundColor=[UIColor yellowColor];
                [but addTarget:self action:@selector(jiaJBut:) forControlEvents:UIControlEventTouchUpInside];
                [dingDanView addSubview:but];
                
                
            }
            labelH=[[UILabel alloc]initWithFrame:CGRectMake(dingDanView.frame.size.width/2-100, 80+40, 100,50)];
            labelH.backgroundColor=[UIColor blueColor];
            labelH.textColor=[UIColor whiteColor];
            labelH.font=[UIFont boldSystemFontOfSize:20];
            labelH.textAlignment=NSTextAlignmentCenter;
            labelH.text=@"0";
            
            
            [dingDanView addSubview:labelH];
            labelS=[[UILabel alloc]initWithFrame:CGRectMake(dingDanView.frame.size.width/2+30, 120, 100,50)];
            labelS.backgroundColor=[UIColor blueColor];
            labelS.textColor=[UIColor whiteColor];
            labelS.font=[UIFont boldSystemFontOfSize:20];
            labelS.textAlignment=NSTextAlignmentCenter;
            labelS.text=@"0";
            [dingDanView addSubview:labelS];
            for (int i=0;i<2;i++)
            {
                UIButton*queR=[[UIButton alloc]initWithFrame:CGRectMake(0+(2+dingDanView.frame.size.width/2)*i, 80+90+10+20+50-5, dingDanView.frame.size.width/2, 50)];
                NSArray*ary=[NSArray arrayWithObjects:@"确认",@"取消", nil];
                [queR setTitle:ary[i] forState:UIControlStateNormal];
                [queR setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                queR.backgroundColor=[UIColor whiteColor];
                queR.tag=i;
                [queR addTarget:self action:@selector(queRBut:) forControlEvents:UIControlEventTouchUpInside];
                [dingDanView addSubview:queR];
            }
            
            NSLog(@"3");

            
            
            NSLog(@"4");
        }
            break;
        case 8:
        {
            jiaoYiView=[[UIView alloc]initWithFrame:CGRectMake(20, 150, WIDE-40, 200)];
           jiaoYiView.backgroundColor=[UIColor grayColor];
            [self.view addSubview:jiaoYiView];
            UILabel*zY=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 50, 30)];
            zY.text=@"注意";
            zY.font=[UIFont boldSystemFontOfSize:20];
            zY.textColor=[UIColor greenColor];
            [jiaoYiView addSubview:zY];
            UIButton*zYBut=[[UIButton alloc]initWithFrame:CGRectMake(jiaoYiView.frame.size.width-30, 10,20,20)];
            [zYBut setImage:[UIImage imageNamed:@"关闭"] forState:UIControlStateNormal];
            [zYBut addTarget:self action:@selector(guanBiBut) forControlEvents:UIControlEventTouchUpInside];
            [jiaoYiView addSubview:zYBut];
            UILabel*label1=[[UILabel alloc]initWithFrame:CGRectMake(0,50, jiaoYiView.frame.size.width, 2)];
            label1.backgroundColor=[UIColor greenColor];
            [jiaoYiView addSubview:label1];
            UILabel*label2=[[UILabel alloc]initWithFrame:CGRectMake(10,80, jiaoYiView.frame.size.width-20,70)];
            label2.font=[UIFont boldSystemFontOfSize:15];
            label2.numberOfLines=0;
            label2.text=@"7天担保交易默认开启，卖家将在7天后才能结算，买家购物更有保障！";
            label2.textColor=[UIColor blackColor];
            [jiaoYiView addSubview:label2];

            NSLog(@"5");
        }
            break;
        default:
            break;
    }
}
-(void)guanBiBut
{
    [jiaoYiView removeFromSuperview];
}
-(void)queRBut:(UIButton*)sender
{
    if (sender.tag==1)
    {
        [dingDanView removeFromSuperview];
    }
    
    
    
    _time1=labelH.text;
    _time2=labelS.text;
    [self ziYingShangPin];
    [dingDanView removeFromSuperview];
    NSLog(@"+++%@,++++%@",_time1,_time2);
    
    
    
}
-(void)jiaJBut:(UIButton*)sender
{
    switch (sender.tag) {
        case 0:
        {
            //            if (self.count<=0) {
            //                return;
            //            }
            self.a ++;
            labelH.text = [NSString stringWithFormat:@"%d",self.a ];
            
        }
            break;
        case 1:
        {
            if (self.a <=0) {
                return;
            }
            self.a  --;
            labelH.text = [NSString stringWithFormat:@"%d",self.a ];
            
        }
            break;
        default:
            break;
    }
    switch (sender.tag) {
        case 2:
        {
            //            if (self.count<=0) {
            //                return;
            //            }
            self.b  ++;
            labelS.text = [NSString stringWithFormat:@"%d",self.b ];
            
        }
            break;
        case 3:
        {
            if (self.b <=0) {
                return;
            }
            self.b  --;
            labelS.text = [NSString stringWithFormat:@"%d",self.b ];
            
        }
            break;
        default:
            break;
    }
    
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage * image = info[UIImagePickerControllerOriginalImage];
    [self dismissViewControllerAnimated:YES completion:nil];
    if (_c==1)
    {
        //_image=image;
        //headImage.image=image;
        [self touXiang];
        [HttpsManager requestToUploadImage:image completion:^(int errcode, NSString *errmsg,NSString*imaged)
         {
             NSString*str=[NSString stringWithFormat:@"%d",errcode];
             if ([str isEqualToString:@"0"])
             {
                 SHOW_ALERT(errmsg);
                 // _zhaoPai=@"已上传";
                 //  [_tabelView reloadData];
                 headImage.image=image;
                 //[headImage sd_setImageWithURL:[NSURL URLWithString:image]];
                 // _imageName=image;
                 // _image=@"http://121.42.211.76:8080/images/user/6/avatar.png";
                 //[_tabelView reloadData];
                 //return;
                 
             }
             SHOW_ALERT(errmsg);
             
         }];
        [self dismissViewControllerAnimated:YES completion:nil];
    }    if (_c==2)
    {
        
        
  UIImage *dian = [self scaleFromImage:image toWidth:WIDE];
        
        [HttpsManager requestDianPuZhaoPaiImage:dian completion:^(int errcode, NSString *errmsg) {
            
            
            NSString*str=[NSString stringWithFormat:@"%d",errcode];
            if ([str isEqualToString:@"0"])
            {
                SHOW_ALERT(errmsg);
               // _zhaoPai=@"已上传";
                
                //_image=image;
                //[_tabelView reloadData];
                return ;
                
            }
            SHOW_ALERT(errmsg);
            
            
            
            
        }];
        
    }

}
- (UIImage *)scaleFromImage:(UIImage *) image toWidth:(CGFloat)width
{
    UIImage * newimage;
    
    if (image == nil) {
        
        newimage = nil;
        
    }else {
        
        CGSize oldSize = image.size;
        
        CGSize newSize;
        newSize.width = width;
        newSize.height = (oldSize.height/oldSize.width)*width;
        
        UIGraphicsBeginImageContext(newSize);
        [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
        newimage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
    
    return newimage;
}

-(void)backBut
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)gengXin
{
    GengXinDianPuZiLiao*vc=[[GengXinDianPuZiLiao alloc]init];
    vc.name=nameField.text;
    vc.wechat=weatchField.text;
    vc.phone=phoneField.text;
    
    vc.closeminute=dingDanLabel1.text;
    NSLog(@"zzzd%@",vc.closeminute);
    [HttpsManager regquestGengXin:vc completion:^(int errcode, NSString *errmsg)
     {
         NSString*str=[NSString stringWithFormat:@"%d",errcode];
         if ([str isEqualToString:@"0"])
         {
             SHOW_ALERT(errmsg);
             return ;
         }
         SHOW_ALERT(errmsg);
     }];

}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
